#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int a, b;
	cin >> a >> b;
	string ans;
	while (1) {
		int t = a % b;
		if (t > 9)
			ans += t - 10 + 'a';
		else
			ans += to_string(t);
		a /= b;
		if (!a)	break;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}
